import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '用户组类型',
    align: "center",
    dataIndex: 'groupType_dictText'
  },
   {
    title: '部门',
    align:"center",
    dataIndex: 'groupId_dictText'
   },
   {
    title: '目录',
    align:"center",
    dataIndex: 'pathId_dictText'
   },
   {
    title: '权限标识',
    align:"center",
    dataIndex: 'perms_dictText'
   },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '更新日期',
    align:"center",
    dataIndex: 'updateTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '目录',
    field: 'pathId',
    component: 'JTreeSelect',
    componentProps:{
      dict:"network_path,name,id",
      pidValue:"0",
    },
  },
  {
    label: '用户组类型',
    field: 'groupType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "group_type"
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '目录',
    field: 'pathId',
    component: 'JTreeSelect',
    componentProps:{
        dict:"network_path,name,id",
        pidValue:"0",
    },
  },
  {
    label: '用户组类型',
    field: 'groupType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "group_type"
    },
    dynamicRules: () => {
      return [
        {required: true, message: '请选择用户组类型!'},
      ];
    },
  },
  {
    label: '角色',
    field: 'groupId',
    component: 'JSelectRole',
    show: ({model}) => {
      return model.groupType == 1;
    },
    dynamicRules: ({model}) => {
      return [
        {required: model.groupType == 1, message: '请选择角色!'},
      ];
    },
  },
  {
    label: '部门',
    field: 'groupId',
    component: 'JSelectDept',
    show: ({model}) => {
      return model.groupType == 2;
    },
    dynamicRules: ({model}) => {
      return [
        {required: model.groupType == 2, message: '请选择部门!'},
      ];
    },
  },
  {
    label: '权限标识',
    field: 'perms',
    component: 'JSelectMultiple',
    componentProps:{
        dictCode:"network_path_perm"
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
